package Sort;

import java.util.Arrays;

public class ShellSort {
    public static void main(String[] args) {
        int[] array = {10,3,2,4,5,2,5,7};
        shellSort(array);
        System.out.println(Arrays.toString(array));
    }
    public static void shellSort(int[] array) {
        int size = array.length;
        for (int gap = size >>> 1; gap >= 1; gap >>>= 1) {
            for (int i = gap; i < size; i++) {
                int key = array[i];
                int j = i - gap;
                while (j >= 0 && array[j] > key) {
                    array[j+gap] = array[j];
                    j -= gap;
                }
                array[j + gap] = key;
            }
        }
    }
}
